<include file="Public:header" />
<script type="text/javascript" src="__PUBLIC__/js/kindeditor-all-min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/zh_CN.js"></script>
<link rel="stylesheet" href="__PUBLIC__/css/kindeditor.css" type="text/css" />
<script type="text/javascript">
	<if condition="C('ismobile') neq 1">
		var editor;
		KindEditor.ready(function(K) {
			editor = K.create('textarea[name="content"]', {
				uploadJson:'__APP__/index.php/File/editor/',
				allowFileManager : true,
				loadStyleMode : false,
				fileManagerJson: "__APP__/index.php/File/manager/"
			});
		});
	</if>
</script>
<div class="container">
	<!-- Docs nav ================================================== -->
	<div class="page-header">
		<h4>新增 产品信息</h4>
	</div>
	<div class="row">
		<div class="span12">
			<include file="Public:alert" />
			<form action="__APP__/index.php/Product/add/" method="post" enctype="multipart/form-data">
				<input  type="hidden" name="role_id" value="{$Think.session.role_id}"/>
				<table class="table" border="0" cellspacing="1" cellpadding="0">
					<thead>
						<tr>
							<td colspan="2"><input name="submit" class="btn btn-primary" type="submit" value="保存"/>&nbsp; <input class="btn btn-primary" name="submit" type="submit" value="保存 & 新增"/> &nbsp;<input class="btn" type="button" onclick="javascript:history.go(-1)" value="返回"/></td>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<td colspan="2"><input class="btn btn-primary"  name="submit" type="submit" value="保存"/> &nbsp;<input class="btn btn-primary" type="submit" value="保存 & 新增"/>&nbsp; <input class="btn" type="button" onclick="javascript:history.go(-1)" value="返回"/></td>
						</tr>
					</tfoot>
					<tbody>
						
						<tr>
							<td class="tdleft">产品名称</td>
							<td><input class="span3" type="text" name="name" id="name" size="80" placeholder="请输入标题"></td>
						</tr>
						<tr>
							<td class="tdleft">目录</td>
							<td>
								<select name="category_id">
								    <option value="">选择目录</option>
									<volist  name="category_list" id="vo">
									<option value="{$vo.id}">{$vo.name}</option>
									</volist>
								</select>
							</td>
						</tr>
						<tr>
							<td class="tdleft">产品详情</td>
							<td>
								<textarea name="content" id="content" style="width: 800px; height: 350px;"></textarea>
							</td>
						</tr>
						<tr>
							<td class="tdleft">产品图片</td>
							<td id="fileTD">
							 <input type="file" name="imgfile" id="file_more" /> 554px * 323px    <a href="javascript:;" id="moreFile" style="margin-right:200px;color:red;display:block;float:right;">更多图片</a>
							</td>
						</tr>
						<tr>
							<td class="tdleft">产品排序</td>
							<td>
								<input type="text" name="sort" id="sort" size="10" placeholder="排序" value="100" />
							</td>
						</tr>
						<tr>
							<td class="tdleft">首页显示</td>
							<td>
							 <input type="radio" name="istop" value="1" <if condition="$vo.istop eq 1">checked</if>>  显示       
                              <input type="radio" name="istop" value="0" <if condition="$vo.istop eq 0">checked</if>>  不显示
							</td>
						</tr>
					</tbody>
				</table>
			</form>

		</div>
	</div>
</div>
<script type="text/javascript">
	<if condition="C('ismobile') eq 1">
		width=$('.container').width() * 0.9;
		$("#content").css({
			width : width
		});
	</if>
	$("input[name='submit']").click(function(){	
		$("#content").html(editor.html());
		if($("#content").val() == null || $("#content").val() == ""){
			alert('详情不能为空');
			return false;
		}

		if($("select[name='category_id'] option:selected").val()==null||$("select[name='category_id'] option:selected").val()==""){
			alert("请选择目录");
			return false;
		}
		
	});
	
	$("#moreFile").click(function(){
		$("#fileTD").append('<div><img src="/Public/images/icons/delet.jpg" style="display:block;float:left;margin-right:15px;" onclick="\$(this).parent().remove();" />    <input type="file" name="morefile[]" /> </div>');
	});
	
	
	$(".fa-puzzle-piece").parent().parent().addClass("active");
    $(".fa-gift").parent().parent().addClass("active");
</script>
<include file="Public:footer" />